#ifndef CLIENTDIALOG_H
#define CLIENTDIALOG_H

#include <QDialog>
#include <QTcpSocket>
#include <scheduleconflicts.h>
#include <schedulepopulation.h>

namespace Ui {
class ClientDialog;
}

class ClientDialog : public QDialog {
    Q_OBJECT
public:
    ClientDialog(QWidget *parent = 0);
    ~ClientDialog();
    void unpackConflicts(QString);
    void unpackPopulation(QString);
    QString packPopulation(SchedulePopulation*);

    enum MessageType{
        POPULATION = 1,
        CONFLICT = 2,
        TIMESLOTS = 3
    };

protected:
    void changeEvent(QEvent *e);

private:
    Ui::ClientDialog *ui;
    QTcpSocket *socket;
    quint16 size;

    void sendMessage(QString message);
    ScheduleConflicts* sc;
    int timeSlots;
    SchedulePopulation* sPop;

private slots:
    void on_ConnectBtn_clicked();
    void receiveMessage();
    void displayError(QAbstractSocket::SocketError);
};

#endif // CLIENTDIALOG_H
